import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

//路由捕错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err);
}

const routes = [{
    path: "/",
    name: "main",
    //异步路由加载
    component: () =>
        import ( /* webpackChunkName:'importCom'   */ '../views/Main.vue')
}, {
    path: "/productdetail",
    name: "productdetail",
    component: () =>
        import ( /* webpackChunkName:'importCom'   */ '../components/ProductDetail/ProductDetail.vue')

}, {
    path: "/cart",
    name: "cart",
    component: () =>
        import ( /* webpackChunkName:'importCom'   */ '../components/Cart/Cart.vue')

}, {
    path: "/accounts",
    name: "accounts",
    component: () =>
        import ( /* webpackChunkName:'importCom'   */ '../components/Accounts/Accounts.vue')
}, {
    path: "/payment",
    name: "payment",
    component: () =>
        import ( /* webpackChunkName:'importCom'   */ '../components/Payment/Payment.vue')
}, {
    path: "/order",
    name: "order",
    component: () =>
        import ( /* webpackChunkName:'importCom'   */ '../components/Order/Order.vue')
}, {
    path: "/address",
    name: "address",
    component: () =>
        import ( /* webpackChunkName:'importCom'   */ '../components/Address/Address.vue')
}]

const router = new VueRouter({
    routes
})

export default router